<?php
// +----------------------------------------------------------------------
// | RecentComments(最新评论
// +----------------------------------------------------------------------
// | @link ( http://www.yurnero.net )
// +----------------------------------------------------------------------
// | @copyright
// +----------------------------------------------------------------------
// | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author Haijun Wu <nicholasinlove@126.com>
// +----------------------------------------------------------------------
// | $Id: RecentCommentsWidget.class.php 123 2011-05-18 09:46:17Z nicholasinlove1986@gmail.com $
// +----------------------------------------------------------------------


class RecentCommentsWidget extends Widget {

	/**
	 * 构造最新评论
	 * 
	 */
	public function render($data) {
	
		$path  =  ROOT_PATH . STATIC_CACHES_DIR;
		$com   =  f_static_cache('comment_static','',$path);
		$ss    =  f_static_cache('statistics_static','',$path);
		$start = ($ss['comment_num'] < C('recent_comments_num')) ? 0 : C('recent_comments_num');
		
	    $output = '';
		$output .= '<!-- Recent Comments: START -->'."\n";
		$output .= " <li class=\"widget widget_recent_comments dbx-box\">\n";
		$output .= "  <h3 class=\"dbx-handle\">Recent Comments</h3>\n";
		$output .= "   <ul class='dbx-content'>\n";
		$k = 1;
		foreach ($com as $v) {
			$output .= "    <li id=\"rc_item_".$k++."\" class=\"rc_item\">\n";
			$output	.= "     <div class=\"rc_avatar rc_left\"><img src=\"".$v['comment_email']."\" class=\"avatar avatar-32 photo\" width=\"32\" height=\"32\" /></div>\n";
			$output .= "     <div class=\"rc_info\"><span class=\"author_name\"><a rel=\"nofollow\" href=\"".__APP__."/Posts/".$v['posts_url']."#comment-".$v['comment_id']."\" title=\"".$v['posts_title']."\">".$v['comment_author']."</a></span></div>\n";
			if ($v['comment_ellipsis']) {
				$output .= "     <div class=\"rc_excerpt\">".convert_smilies($v['comment_short_content'])."<span class=\"rc_expand\"><a rel=\"nofollow\" href=\"javascript:void(0);\" onclick=\"RCJS.detail(".$v['comment_id'].",'__APP__/Comment/detailComment',0,'Loading');\">»</a></span></div>\n";
			} else {
				$output .= "     <div class=\"rc_excerpt\">".convert_smilies($v['comment_short_content'])."</div>\n";
			}
			$output .= "    </li>\n";	
		}
		if ($start) {
			$output .= "    <li class=\"rc_navi rc_clearfix\"><div id=\"rc_older\"><a rel=\"nofollow\" href=\"javascript:void(0);\" onclick=\"RCJS.page('__APP__/Comment/recentComment','".$start."','Loading');\">Older &raquo;</a></div></li>\n";
		}
		$output .= "   </ul>\n";
		$output .= " </li>\n";
		$output .= ' <!-- Recent Comments: END -->'."\n";
		
		return $output;
	}
	
}

?>